<template>
  <BasicTable
    :initial-params="initialParams"
    :query-api="dcDeviceLog.queryAll"
    :query-fields="queryFields"
    :table-fields="tableFields"
    :has-add="false"
  ></BasicTable>
</template>

<script setup lang="tsx">
import { dcDeviceLog } from "../../api/dcDeviceLog";
import BasicTable from "../../components/BasicTable";
import parseTime from "../../utils/parseTime";

const initialParams = {
  limit: 99999,
};

const queryFields = [
  {
    prop: "name",
    title: "时间",
    slot: (params) => (
      <el-date-picker
        v-model={params.value.time}
        type="datetimerange"
        value-format="YYYY-MM-DD HH:mm:ss"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
      />
    ),
  },
];

const tableFields = [
  {
    prop: "data1",
    title: "数值1",
  },
  {
    prop: "data2",
    title: "数值2",
  },
  {
    prop: "data3",
    title: "数值3",
  },
  {
    prop: "device",
    title: "设备编号",
  },
  {
    prop: "map",
    title: "地图",
  },
  {
    prop: "type",
    title: "类型",
  },
  {
    prop: "createTime",
    title: "异常时间",
    formatter: (row) => {
      return parseTime(row);
    },
  },
];
</script>
